package com.heima.controller.vm;

import com.heima.common.PageResult;
import com.heima.common.Result;
import com.heima.pojo.VmType;
import com.heima.pojo.dto.VmPageDTO;
import com.heima.service.VmService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/api/vm-service/vmType")
public class VmTypeController {
    @Autowired
    private VmService vmService;

    /**
     * 售货机类型列表(搜索)
     */
    @GetMapping("/search")
    public PageResult searchVm(VmPageDTO vmPageDTO){
        return vmService.pageQuery(vmPageDTO);
    }

    /**
     * 新增设备类型
     */
    @PostMapping
    public Result add(@RequestBody VmType vmType){
        return vmService.add(vmType);
    }

    /**
     * 售货机类型修改
     */
    @PutMapping("/{typeId}")
    public Result update(@PathVariable Integer typeId ,@RequestBody VmType vmType ){
        vmService.update(typeId,vmType);
        return Result.success();
    }

    /**
     * 售货机类型删除
     */
    @DeleteMapping("/{typeId}")
    public Result delete(@PathVariable Integer typeId){
        vmService.delete(typeId);
        return Result.success();
    }


}
